/**
 * Created by zhangyunqi on 2017/6/11.
 */

import java.util.ArrayList;
import java.util.List;


public class Prefix {
    public List <String> pref;

    //n copies of str

    public Prefix(int npref, String word) {
        pref = new ArrayList <String> ();
        for (int i = 0; i < npref; i++) {
            pref.add ( word );
        }
    }


    public Prefix(Prefix prefix) {
        this.pref = new ArrayList <String> ( prefix.pref );
    }

    private static final int MULTIPLIER = 31;

    public int hashCode() {
        int h = 0;
        for (int i = 0; i < pref.size (); i++) {
            h = h * MULTIPLIER + pref.get ( i ).hashCode ();
        }
        return h;
    }


    public boolean equals(Object o) {
        Prefix p = (Prefix) o;
        for (int i = 0; i < pref.size (); i++) {
            if (!pref.get ( i ).equals ( p.pref.get ( i ) )) {
                return false;
            }
        }
        return true;
    }

}

